package com.ttg.web.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.model.mapper.AgentMapper;
import com.ttg.model.pojo.Agent;
import com.ttg.web.service.AgentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author huyangzou
 * @create 2020-11-27 16:45
 */
@Slf4j
@Service
public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements AgentService {

    @Override
    public Agent getAgentByAgentNo(Long agentNo) {
        LambdaQueryWrapper<Agent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(Agent::getAgentNo,Agent::getAgentStatus);
        queryWrapper.eq(Agent::getAgentNo,agentNo);
        return super.getOne(queryWrapper);
    }

    @Override
    public Agent getAgentByAgentNoAndOrgNo(Long agentNo, Long agentOrgNo) {
        LambdaQueryWrapper<Agent> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Agent::getAgentOrgNo, agentOrgNo)
                .eq(Agent::getAgentNo, agentNo);
        return getOne(wrapper);
    }
}
